#!/usr/bin/env python3

import sys
import plx
import os

if len(sys.argv) < 2:
    print("Usage: plx-install <package> [install_path]")
    sys.exit(1)

if os.geteuid() != 0:
    print("Permission Denied")
    sys.exit(1)

file = sys.argv[1]
inst_path = "/"

if len(sys.argv) == 3:
    inst_path = sys.argv[2]

f = open(file)
pcks = f.readlines()

for pck in pcks:
    if not plx.install_package(pck.rstrip(), inst_path):
        print("Installation failed")
        sys.exit(1)

print("Installation of " + file + " Complete")
